package xyz.xtgl.oauth2.config.helper;

import common.core.util.CommonUtil;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;

/** Jwt token 扩展
 * @author liubo
 * @created 2019-12-26 16:46
 */
public class CustomJwtAccessTokenConverter extends JwtAccessTokenConverter {

    @Override
    public OAuth2AccessToken enhance(OAuth2AccessToken oAuth2AccessToken, OAuth2Authentication oAuth2Authentication) {
        DefaultOAuth2AccessToken token = (DefaultOAuth2AccessToken)super.enhance(oAuth2AccessToken,oAuth2Authentication);
        if(CommonUtil.isNotEmpty(oAuth2Authentication.getUserAuthentication())){
            Authentication authentication = oAuth2Authentication.getUserAuthentication();
            if(CommonUtil.isNotEmpty(authentication)){

            }
        }
        return token;
    }
}